﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using db;
using System.Collections;

namespace DMSMT.MaterialMgr
{
    public partial class CYXXFrm : Form
    {
        public CYXXFrm()
        {
            InitializeComponent();
        }

        private void btSearch_Click(object sender, EventArgs e)
        {
            string ddcode = tbDD.Text.Trim();
            string cycode = tbCY.Text.Trim();
            string err = "";
            if (string.IsNullOrEmpty(ddcode))
            {
                err += "订单号不能为空!\r\n";
            }
            else
            {
                if (ddcode.Length < 6)
                {
                    err += "订单号格式不对!\r\n";
                }
            }
            if (string.IsNullOrEmpty(cycode))
            {
                err+="发运单号不能为空!";
            }
            if (!string.IsNullOrEmpty(err))
            {
                MessageBox.Show(err);
                return;
            }
            string sql = "select sa.net_code,sa.delivery_no,sa.delivery_id,sa.bill_code from TT_PT_SALE_ORDER sa where sa.refer_code='" + ddcode + "'";
            Hashtable ht=Dao.select("zj",sql);
            if (ht == null || ht.Count == 0)
            {
                Log.LogText(ddcode + "订单号未回写对应的销售单号!\r\n");
            }
            else
            {
                Log.LogText(ddcode + "订单号对应的销售单!\r\n");
                Log.LogText("-----------------------------\r\n");
                Log.LogText("网点Code:\t" + ht["net_code"] + "\r\n");
                Log.LogText("发运单号:\t" + ht["delivery_no"] + "\r\n");
                Log.LogText("销售单号:\t" + ht["bill_code"] + "\r\n");
                Log.LogText("-----------------------------\r\n");
            }
            string netcode = ddcode.Substring(2,4);
            sql = "select * from T_PA_CARRY ca where ca.carry_no='"
                + cycode +
                "' and net_code=" + netcode;
            Log.LogText(sql + "\r\n");
            ht = Dao.select("zj", sql);
            if (ht == null || ht.Count == 0)
            {
                Log.LogText(cycode + "发运单号未回写!\r\n");
            }
            else
            {
                Log.LogText(cycode + "发运单号已回写!\r\n");
            }

        }
    }
}
